<template>
  <div class="my-goods-item">
    <div class="left">
      <div class="custom-control custom-checkbox">
        <!-- checked设置接收父组件的初始值, 勾选改变时调用父组件对应函数 -->
        <input
          type="checkbox"
          class="custom-control-input"
          id="input"
          :checked="item.goods_state"
          @input="$emit('input')"
        />
        <label class="custom-control-label" for="input">
          <img :src="item.goods_img" alt="" />
        </label>
      </div>
    </div>
    <div class="right">
      <!-- 商品名称 -->
      <div class="top">{{ item.goods_name }}</div>
      <div class="bottom">
        <!-- 商品价格 -->
        <span class="price">{{ item.goods_price }}¥</span>
        <span>
          <slot><!-- 预留数量组件位置 --></slot>
        </span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['item'],
}
</script>

<style lang="less" scoped>
.my-goods-item {
  display: flex;
  padding: 10px;
  border-bottom: 1px solid #ccc;
  .left {
    img {
      width: 120px;
      height: 120px;
      margin-right: 8px;
      border-radius: 10px;
    }
    .custom-control-label::before,
    .custom-control-label::after {
      top: 50px;
    }
  }
  .right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .top {
      font-size: 14px;
      font-weight: 700;
    }
    .bottom {
      display: flex;
      justify-content: space-between;
      padding: 5px 0;
      align-items: center;
      .price {
        color: red;
        font-weight: bold;
      }
    }
  }
}
</style>
